<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>生成PNRbornPNR</title>
	</head>
	<link rel="stylesheet" href="../css/common.css" />
	<style>
		#box{
			margin-top:50px;
			width:380px;
			text-align:right;
		}
		input,select{
			width:190px;
			height:27px;
			padding-left:20px;
			border:1px solid #dadada;
			margin-left:10px;
		}
		select{
			width:212px;
		}
		.right{
			float:right;
		}
		#box>div{
			margin-top:10px;
			padding-left:
		}
		#box>div:last-child{
			margin-top:30px;
		}
		button{
			width:100px;
			height:28px;
			border-radius:2px;
			cursor:pointer;
			color:white;
			background:#a1a4a9;
			border:none;
		}
		.sure{
			background:#00aa98;
			margin-right:11px;
		}
	</style>
	<body>
		<div id="box">
			<div>舱位代码<input class="cabinCode" type="text"></div>
			<div>CT项<input class="CT" type="text"></div>
			<div>团队名<input class="groupName" type="text"></div>
			<div>货币类型<select class="currency">
						<option value="CNY">人民币</option>	
						<option value="MYR">马币</option>
					  </select>
			</div>
			<div>OSI项<input class="OSI" type="text"></div>
			<div>票面款<input class="facePrice" type="number" step="0.01"></div>
			<div>实收款<input class="salePrice" type="number" step="0.01"></div>
			<div><div><button class="sure">确认</button><button class="cancel">取消</button></div></div>
		</div>
		<script type="text/javascript" src="../js/jquery-1.12.4.js" ></script>		
		<script type="text/javascript" src="../js/common.js" ></script>
		<script type="text/javascript" src="../layer-v2.4/layer/layer.js" ></script>
		<script>
			
			$(".cancel").click(function(){
				closeWin();
			})
			$(".sure").click(function(){
				var orderId = getHref().orderId;			
				var postData = {
					    "orderId":orderId,
					    "cabinCode":$(".cabinCode").val(),
					    "CT":$(".CT").val(),
					    "groupName":$(".groupName").val(),
					    "currency":$(".currency").val(),
					    "OSI":$(".OSI").val(),
					    "facePrice":$(".facePrice").val(),
					    "salePrice":$(".salePrice").val()
					};
									
				if(Number(postData.salePrice)>Number(postData.facePrice)){
					layer.msg("实收款不能大于票面款",{"icon":2});		
					return false;
				}				
				//提交
				layer.confirm('确定生成PNR？', {
				  	btn: ['确定','取消'] //按钮
				}, function(){
				 	sure();	
				});	
				
				function sure(){
					layer.load();
					$.ajax({
						type:"post",
						url:"../ticket/generatePNR?temp="+Math.random(),
						contentType:'application/json;charset=utf-8',
						data:JSON.stringify(postData),
						dataType:"json",
						async:true,
						success:function(data){
							layer.closeAll('loading');
							if(data.status=="1001"){
								layer.msg('生成PNR成功', {icon: 1,time:1000},function(){
									var index = parent.layer.getFrameIndex(window.name);//获取弹窗索引
									parent.layer.close(index);//关闭弹窗
								});			
							}else{							
								layer.confirm(data.message, {
									title:['生成PNR失败','background-color:#6d6e72;color:#fff'],
								   	btn: ['确定'] //按钮
								}, function(){
									layer.closeAll('dialog');
								});
							}
						}
					});
				}
				
			})
			
			$(".salePrice,.facePrice").blur(function(){
				var a = $(this).val();
				$(this).val(Number(a).toFixed(2));
			})
			
		</script>
	</body>
</html>
